<?php
include_once "Product.php";

class ProductControl
{
	public static function cadastreProduct($idAdm ,$label_name, $label_country, $label_quantity, $label_amount, $label_description)
	{
		$product = Product::InsertProductAdministrator($idAdm, $label_name, $label_description, $label_country, $label_amount, $label_quantity);
		return $product;
	}
	
	public static function cadastreProductClient($idCliente, $label_name, $label_country, $label_quantity, $label_amount, $label_description)
	{
		$product = Product::InsertProductAdministrator($idCliente, $label_name, $label_description, $label_country, $label_amount, $label_quantity);
		return $product;
	}
	
	public static function atualizaProduto($idProduto, $label_name, $label_quantity, $label_amount, $label_type,
	$label_artist, $label_country, $label_description)
	{
		$result = Product::UpdateProductAdministrator($idProduto, $label_name, $label_quantity, $label_amount, 
	$label_type, $label_artist, $label_country, $label_description);
		if($result)
		{
			return true;		
		}
		else
		{
			return false;
		}
		
	}
	
	public static function InsertPhoto($file_content,  $type , $product_Id)
	{
		Product::InsertPhoto($file_content, $type ,$product_Id);
	}
	
	public static function InsertProductAtCategory($category, $product_Id)
	{
		Product::InsertProductAtCategory($category, $product_Id);
	}
	
	public static function GetProdutoPaginaInicial()
	{
		//alterar pra pegar produtos diferentes por vez
		
		$products = Product::GetAllOfficialProducts(null, null);
		
		$index = 0;
		$count = 0;
		$top4Products = array();
		while($count < 4 and $index < count($products))
		{
			if($products[$index]->Fotos != null)
			{
				$top4Products[$count] = $products[$index];
				$count++;
			}
			$index++;
		}
	
		return $top4Products;
		
	}
	
	public static function GetProdutoSearch($searchWord)
	{
		$products = Product::GetAllOfficialProducts(null, $searchWord);
		return $products;
	}
	
	public static function GetProdutoCategoria($categoria)
	{
		$products = Product::GetAllOfficialProducts($categoria, null);
		return $products;
	}
	
	public static function GetProdutoById($idProduto)
	{
		$resultProduto = Product::GetProduto($idProduto);
		return $resultProduto;
		
	}
	
	public static function getProdutoOficial($id_product)
	{
		return Product::GetProductOficial($id_product);
	}
}

?>
